const app = getApp();
import { jiatuiRequest } from "/utils/requests";
Page({
  /**
   * 页面的初始数据
   */
  data: {
    showContact: true,
    suspendShow: true,
    showIcon: true,
    bgcolor: '',
    form: true,
    table: false,
    options: {
      s1: 'y',
      xiangmu: "sk",
      lx: "sk",
      selectNo: 'y',
    },
    yl: 1,
    gonghao: '无',
    fenxiao: '无',
    laiyuan: '河北省直职位查询',
    chaxunjg: '',
    cxlists: [],
    showIcon: !0,
    isShowAuth: !1,
    isShowCdNav: !1,
    onReachBottomNum: 0,
    listId: 1,
    lists: [{
      'title': '按个人条件查询',
      "zt": 'on'
    }, {
      'title': '按职位信息查询',
      "zt": ''
    }],
    nav: 1,
    zwid: 12,
    actid: 17122,
    name: '',
    title: '',
    cxlists: [], //存放比对过后的所有数据
    cxlists1: [], //存放临时的20条
    collectLists: [], //收藏列表--用于比对，输出当前收藏职位
    collectLen: 0,
    filed: {},
    file: [],
    str1: '',
    str2: '',
    str3: '',
    str1Arr: [],
    str11: [],
    str2Arr: [],
    str22: [],
    str3Arr: [],
    str33: [],
    cxFlag: false,
    zyLevel: 2,
    zylevel2: '',
    zylevel1: '',
    zylevel0: '',
    zydata: {},
    grdata: {
      tabnum: 1
    },
    grscdata: {
      flag: true,
      limits: 60,
      tabnum: 3
    }, //个人收藏条件
    qxdata: {
      flag: true,
      tabnum: 3
    }, //取消个人收藏条件
    areaRst: '',
    xueliRst: '',
    xueweiRst: '',
    zldxRst: '',
    zzmmRst: '',
    sexRst: '',
    sfyjRst: '',
    areaArr: [{
      id: "2_1",
      text: "不限"
    }, {
      id: "2_2",
      text: "石家庄"
    }, {
      id: "2_3",
      text: "保定"
    }, {
      id: "2_4",
      text: "唐山"
    }, {
      id: "2_5",
      text: "承德"
    }, {
      id: "2_6",
      text: "邯郸"
    }, {
      id: "2_7",
      text: "沧州"
    }, {
      id: "2_8",
      text: "秦皇岛"
    }, {
      id: "2_9",
      text: "张家口"
    }, {
      id: "2_10",
      text: "廊坊"
    }, {
      id: "2_11",
      text: "衡水"
    }, {
      id: "2_12",
      text: "邢台"
    }, {
      id: "2_13",
      text: "天津"
    }, {
      id: "2_14",
      text: "雄安新区"
    }],
    xueliArr: [{
      id: "3_1",
      text: "不限"
    }, {
      id: "3_2",
      text: "高中"
    }, {
      id: "3_3",
      text: "中专"
    }, {
      id: "3_4",
      text: "专科"
    }, {
      id: "3_5",
      text: "本科"
    }, {
      id: "3_6",
      text: "研究生"
    }],
    bklx: [{
      id: "5_1",
      text: "综合岗"
    }, {
      id: "5_2",
      text: "教育岗"
    }, {
      id: "5_3",
      text: "医疗岗"
    }],
    xueweiArr: [{
      id: "6_1",
      text: "不限"
    }, {
      id: "6_2",
      text: "学士"
    }, {
      id: "6_3",
      text: "硕士"
    }, {
      id: "6_4",
      text: "博士"
    }],
    sexArr: [{
      id: "7_1",
      text: "女"
    }, {
      id: "7_2",
      text: "男"
    }, {
      id: "7_2",
      text: "不限"
    }],
    zzmmArr: [{
      id: "8_1",
      text: "共青团员"
    }, {
      id: "8_2",
      text: "中共党员"
    }, {
      id: "8_3",
      text: "群众"
    }, {
      id: "8_4",
      text: "不限"
    }],
    zldxArr: [{
      id: "9_1",
      text: "2年以上基层工作经历"
    }, {
      id: "9_2",
      text: "2年以上相关工作经历"
    }, {
      id: "9_3",
      text: "服务基层项目人员"
    }, {
      id: "9_4",
      text: "北京冬(残)奥会志愿者"
    }, {
      id: "9_5",
      text: "退役运动员"
    }, {
      id: "9_6",
      text: "不限"
    }],
    sfyjArr: [{
      id: "10_1",
      text: "是"
    }, {
      id: "10_2",
      text: "否"
    }],
    fypage: 1,
    zcpages: 1,
    bklxvalue: '',
    zhuanyeFlag: false,
    wx: '',
    myPhone: '',
    isSydw: false,
    limits: 20,
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: async function (options) {
    this.setData(await app.methods.myPhone()); // 获取本地存储手机号
    if(!this.data.myPhone) {
      await app.methods.getPhoneNumber()
      this.setData({
        isShowAuth: !0
      })
    }
    xhs.showShareMenu({
      shareTypes: 'normal',
    })
    let links, jxOptions;
    if (options.scene) {
      options.scene = options.scene.replace(/%253D/g, ".");
      options.scene = options.scene.replace(/%2526/g, "-");
      jxOptions = await app.methods.getOPtions(options);
    }
    let id = options.scene ? jxOptions.id : options.id;
    options.id = id;
    links = await app.methods.getLink(id);
    options.fx = options.scene ? jxOptions.fx : options.fx;
    options.gh = options.scene ? jxOptions.gh : options.gh;
    options.actid = links.actid ? links.actid : '56125';
    options.lx = links.lx ? links.lx : '';
    options.name = links.name ? links.name : '历年职位检索';
    options.ggid = links.ggid ? links.ggid.indexOf('[') >= 0 ? JSON.parse(links.ggid) : links.ggid.indexOf(',') >= 0 ? links.ggid.split(',') : [Number(links.ggid)] : [];
    if (!options.ggid) {
      options.s1 = 'y'
    } else if (options.ggid instanceof Array) {
      if (options.ggid.length == 0 || options.ggid.length > 1) {
        options.s1 = 'y'
      } else {
        options.s1 = 'n'
      }
    } else {
      xhs.showToast({
        title: '配置错误，请联系管理员',
        icon: 'none'
      })
      return false
    }
    if (options.actid == undefined) {
      this.setData({
        actid: '56125'
      })
    }
    if (options.yl != undefined) {
      if (options.yl.length > 0) {
        this.setData({
          yl: Number(options.yl)
        })
      }
    }
    if (options.lx != undefined) {
      if (options.lx.length > 0) {
        this.setData({
          isSydw: true
        })
      }
    }
    this.setData({
      options,
      laiyuan: options.name
    })
    app.globalData.laiyuan = options.name
    this.setData(await app.methods.getIdentity(options)); // 获取个人身份信息
    if (this.data.getIdentity.crm) {
      options.wxh = this.data.getIdentity.crm
    } else {
      options.wxh = options.gh
    }
    this.setData(await app.methods.getWechat(options)); // 获取个人身份信息
    this.setData(await app.methods.guishudi(options)); // 获取归属地
    let fenbu = this.data.fenbu;
    let fenxiao = this.data.fenxiao;
    let getIdentity = this.data.getIdentity;
    getIdentity.fenbu = fenbu;
    getIdentity.fenxiao = fenxiao;
    getIdentity.zzname = this.data.zzname;
    getIdentity.zzid = this.data.zzid;
    getIdentity.erpdqm = this.data.erpdqm;
    this.setData({
      getIdentity: getIdentity
    })

    let res = await this.levelOne();
    if(options.ggid.length == 1) {
      this.setData({
        areaArr: res
      })
    } else {
      this.setData({
        str1Arr: res
      })
    }
    this.data.myPhone == '' ? '' : this.setData(await app.methods.getphonestatusCX(this.data.myPhone, this.data.options.actid, 'chaxun'))
    //查询是否注册并且返回user信息
    this.thisMethod()
  },
  m_select_touch: async function (t) {
    var e = t.detail.selIndex,
      a = t.detail.stype,
      c = t.detail.level,
      d = t.detail.selectId,
      f = t.detail.selectText;
    let searchData = {};
    if (c == 1) {
      // 这里要判断选择不限还是具体年份，然后每种情况要考虑是否存在ggid
      if(f == '不限') {
        if(this.data.options.ggid.length > 0) {
          searchData = {ggid: JSON.stringify(this.data.options.ggid)}
        } else {
          searchData = {}
        }
      } else {
        if(this.data.options.ggid.length > 0) {
          searchData = { 
            ggid: JSON.stringify(this.data.options.ggid),
            year: f
          }
        } else {
          searchData = { year: f }
        }
      }
      jiatuiRequest({
        url: `/api/v1/moonshot/getNoticeName`,
        method: 'GET',
        dataType: 'jsonp',
        header: {
          'X-Requested-From': 'WeChatMiniProgram'
        },
        data: searchData,
      }).then(res => {
        let result = [];
        if (res.code == 0) {
          result = res.data.result;
        } else {
          result = [{ id: "2_1", text: "不限" }]
        }
        this.setData({
          str2Arr: result,
          areaArr: [],
          str1: t.detail.selectText
        })
      }).catch(err => {
        this.setData({
          str2Arr: [{ id: "2_1", text: "不限" }],
          areaArr: [],
          str1: t.detail.selectText
        })
      })
    } else if (c == 2) {
      if (f == '不限') {
        searchData = this.data.options.ggid ? { ggid: JSON.stringify(this.data.options.ggid) } : {}
      } else {
        searchData = { ggid: d }
      }
      this.setData({
        selectGGID: d
      })
      jiatuiRequest({
        url: `/api/v1/moonshot/getCityLists`,
        method: 'GET',
        dataType: 'jsonp',
        header: {
          'X-Requested-From': 'WeChatMiniProgram'
        },
        data: searchData,
      }).then(res => {
        let result = [];
        if (res.code == 0) {
          result = res.data.result;
        } else {
          result = [{ id: "3_1", text: "不限" }]
        }
        let ggid = undefined;
        if(f == '不限') {
          this.data.str2Arr.map(item => {
            item.text != '不限' 
          })
        }
        this.setData({
          areaArr: result,
          str2: f == '不限' ? this.data.options.ggid ? JSON.stringify(this.data.options.ggid) : '不限' : d
        })
      }).catch(err => {
        this.setData({
          areaArr: [{ id: "3_1", text: "不限" }],
          str2: f == '不限' ? this.data.options.ggid ? JSON.stringify(this.data.options.ggid) : null : d
        })
      })
    } else if (c == 3) {
      searchData = this.data.options.s1 !== 'y' ? {
        ggid: JSON.stringify(this.data.options.ggid),
        city: f
      } : {
        ggid: this.data.selectGGID,
        city: f
      }
      this.setData({
        areaRst: f
      })
      jiatuiRequest({
        url: `/api/v1/moonshot/getXianquLists`,
        type: 'GET',
        dataType: 'jsonp',
        header: {
          'X-Requested-From': 'WeChatMiniProgram'
        },
        data: searchData,
      }).then(res => {
        let { code, data } = res;
        let result = [];
        if (code == 0) {
          result = data.result;
        } else {
          result = [{ id: "4_1", text: "不限" }]
        }
        this.setData({
          xianquArr: result,
        })
      }).catch(err => {
        this.setData({
          xianquArr: [{ id: "4_1", text: "不限" }],
        })
      })
    } else if (c == 6) { //非级联--个人选项
      a == 'xueli' ? this.setData({
        xueliRst: t.detail.selectText == '不限' ? '' : t.detail.selectText
      }) : a == 'xuewei' ? this.setData({
        xueweiRst: t.detail.selectText == '无' ? '' : t.detail.selectText
      }) : a == 'zzmm' ? this.setData({
        zzmmRst: t.detail.selectText == '不限' ? '不限' : t.detail.selectText
      }) : a == 'sex' ? this.setData({
        sexRst: t.detail.selectText == '不限' ? '' : t.detail.selectText
      }) : a == 'area' ? this.setData({
        areaRst: t.detail.selectText == '不限' ? '' : t.detail.selectText
      }) : a == 'sfyj' ? this.setData({
        sfyjRst: t.detail.selectText == '不限' ? '' : t.detail.selectText
      }) : this.setData({
        zldxRst: t.detail.selectText == '不限' ? '' : t.detail.selectText
      })
    } else if (c == 5) {
      this.setData({
          bklxvalue: f
      })
  }
  },
  //获取一级信息
  async levelOne() {
    return new Promise((resolve, reject) => {
      let { s1, ggid } = this.data.options;
      if (s1 == 'y') {
        jiatuiRequest({
          url: `/api/v1/moonshot/getYear`,
          method: 'GET',
          dataType: 'jsonp',
          header: {
            'X-Requested-From': 'WeChatMiniProgram'
          },
          data: {
            ggid
          },
        }).then(res => {
          if (res.code == 0) {
            const { result } = res.data;
            resolve(result)
          } else {
            resolve([{ id: "1_1", text: "不限" }])
          }
        }).catch(err => {
          resolve([{ id: "1_1", text: "不限" }])
        })
      } else {
        jiatuiRequest({
          url: `/api/v1/moonshot/getCityLists`,
          method: 'GET',
          dataType: 'jsonp',
          header: {
            'X-Requested-From': 'WeChatMiniProgram'
          },
          data: {
            ggid: this.data.options.ggid
          },
        }).then(res => {
          if (res.code == 0) {
            const { result } = res.data;
            resolve(result)
          } else {
            resolve([{ id: "2_1", text: "不限" }])
          }
        }).catch(err => {
          resolve([{ id: "2_1", text: "不限" }])
        })
      }
    })
  },
  // 选择专业
  m_selectSearch_touch: function (t) {
    var e = t.detail.selText;
    // var e='专科-农林牧渔-农业类-现代农业技术';
    let _index2 = e.lastIndexOf('-') + 1;
    let _index0 = e.indexOf('-') + 1;
    let _index1 = e.indexOf('-', _index0);
    let zy2 = e.substr(_index2, e.length);
    let zy1 = e.slice(_index1 + 1, _index2 - 1);
    let zy0 = e.slice(_index0, _index1);
    this.setData({
      major: zy2 == '不限' ? '不限' : zy2,
      zylevel2: zy2 == '不限' ? '不限' : zy2,
      zylevel1: zy1,
      zylevel0: zy0,
      zydata: {
        'zy0': zy0,
        'zy1': zy1,
        'zy2': zy2,
      },
      zhuanyeFlag: zy2 == '不限' || zy2 == '' ? false : true,
    });
  },

  // 按个人条件查询
  async clickfn() {
    if(!this.data.myPhone) {
      this.setData({
        isShowAuth: !0,
      })
      return false
    }
    if(this.data.options.s1 == 'y') {
      if (!this.data.str1) {
        xhs.showToast({
          title: '请选择年份',
          icon: 'none',
          duration: 2000
        })
        return false
      }
      if (!this.data.str2) {
        xhs.showToast({
          title: '请选择公告',
          icon: 'none',
          duration: 2000
        })
        return false
      }
    }
    if ((this.data.xiangmuok) && (this.data.isSydw) && (this.data.bklxvalue == '')) {
        xhs.showToast({
            title: '请选择备考类型',
            icon: 'none',
            duration: 2000
        })
        return false
    }
    this.setData({
      fypage: 1,
      zyLevel: 2
    })
    let data = {
      year: this.data.str1 == undefined ? '' : this.data.str1,
      ggid: this.data.options.s1 == 'y' ? this.data.str2 == undefined ? '' : this.data.str2 : this.data.options.ggid,
      city: this.data.areaRst != undefined ? this.data.areaRst : '',
      xuewei: this.data.xueweiRst != undefined ? this.data.xueweiRst : '',
      xueli: this.data.xueliRst != undefined ? this.data.xueliRst : '',
      sex: this.data.sexRst != undefined ? this.data.sexRst : '',
      sfyj: this.data.sfyjRst != undefined ? this.data.sfyjRst : '',
      zldx: this.data.zldxRst != undefined ? this.data.zldxRst : '',
      zzmm: this.data.zzmmRst != undefined ? this.data.zzmmRst : '',
      major: this.data.major != undefined ? this.removeNumbersAndLetters(this.data.major) : '不限',
      limits: this.data.limits,
      page: 1,
    }
    this.setData({
      grdata: data,
      table: true,
      form: false,
      chaxunjg: 0,
      cxlists: [],
      allLists: [],
      onReachBottomlists: [],
      onReachBottomNum: this.data.onReachBottomNum + 1
    })
    await this.getUser()
    await this.chaxun(this.data.grdata)
  },
  // 按个人条件查询---专业--一级学科-专业大类--不限专业
  clickfn2: async function (t) {
    var e = t.currentTarget.dataset.zyjb;
    e == 'zy2' ? this.setData({
      zyLevel: 2
    }) : e == 'zy1' ? this.setData({
      zyLevel: 1
    }) : e == 'zy0' ? this.setData({
      zyLevel: 0
    }) : this.setData({
      zyLevel: 'bx'
    })
    if (e != 'zy00') {
      this.setData({
        onReachBottomNum: 0,
        major: this.data.zydata[e],
        ['grdata.major']: this.removeNumbersAndLetters(this.data.zydata[e]),
        ['grdata.page']: 1,
        page: 0,
        table: true,
        chaxunjg: 0,
        cxlists: [],
        allLists: [],
        onReachBottomlists: [],
        onReachBottomNum: this.data.onReachBottomNum + 1
      })
    } else {
      this.setData({
        onReachBottomNum: 0,
        major: '不限',
        ['grdata.major']: '不限',
        ['grdata.page']: 1,
        page: 0,
        table: true,
        chaxunjg: 0,
        cxlists: [],
        allLists: [],
        onReachBottomlists: [],
        onReachBottomNum: this.data.onReachBottomNum + 1
      })
    }
    await this.getUser()
    await this.chaxun(this.data.grdata)
  },
  // 学员信息查询 
  async getUser() {
    if (!this.data.user) {
      await app.methods.registerCX(this.data.myPhone, this.data.options.actid, this.data.laiyuan, this.data.isSydw, this.data.getIdentity, this.data.bklxvalue, '', '', 'chaxun')
      this.setData({
        ['user.user.laiyuan']: this.data.options.name,
        ['xiangmuok']: false
      })
    } else {
      let laiyuan = this.data.user.user.laiyuan;
      if (laiyuan.indexOf(this.data.options.name) < 0) {
        await app.methods.updateuserCX(this.data.myPhone, this.data.options.actid, this.data.laiyuan, this.data.isSydw, this.data.getIdentity, this.data.bklxvalue, '', 'chaxun', '', this.data.user.user)
        this.setData({
          ['user.laiyuan']: this.data.options.name,
          ['xiangmuok']: false
        })
      }
    }
  },
  // 查询数据
  async chaxun(data) {
    return new Promise((resolve) => {
      jiatuiRequest({
        url: '/api/v1/moonshot/getPositionsXcx',
        method: 'GET',
        dataType: 'jsonp',
        header: {
          'X-Requested-From': 'WeChatMiniProgram'
        },
        data,
      }).then(res => {
        if(res.code == 0) {
          let { result, total } = res.data;
          if(total == 0) return xhs.showToast({
            title: '暂无数据',
            icon: 'none',
            duration: 2000
          })
          this.setData({
            chaxunjg: total,
            zcpages: parseInt(total / this.data.limits) + 1,
            cxlists: this.data.cxlists.concat(result),
            allLists: result,
            onReachBottomlists: result,
            onReachBottomNum: this.data.onReachBottomNum + 1
          })
          resolve()
        } else {
          xhs.showToast({
            title: data.message,
            icon: 'none',
            duration: 2000
          })
          resolve()
        }
      }).catch(err => {
        xhs.showToast({
          title: '服务异常，请重试',
          icon: 'none',
          duration: 2000
        })
        resolve()
      })
    })
  },
  // 重新检索
  changetj: function () {
    this.setData({
      table: false,
      form: true,
      allLists: "",
      cxlists: "",
      yearvalue: "",
      addressvalue: "",
      xueliArrvalue: "",
      zzmmvalue: "",
      major: "",
      str1: "",
      str2: "",
      str3: "",
      ['zydata']: {},
      ['grdata']: {},
    })
  },
  // 触底刷新
  async onReachBottom() {
    if (this.data.table) {
      // 获取当前检索总页数---totleCont
      if (((this.data.chaxunjg) % this.data.limits) == 0) {
        var totleCont = parseInt(this.data.chaxunjg / this.data.limits)
      } else {
        var totleCont = parseInt(this.data.chaxunjg / this.data.limits) + 1
      }
      // 计算当前已经展示几屏--当前页码--nowCont
      if (this.data.cxlists.length % this.data.limits == 0) {
        var nowCont = parseInt(this.data.cxlists.length / this.data.limits)
      } else {
        var nowCont = parseInt(this.data.cxlists.length / this.data.limits) + 1
      }
      // 判断是否已经全部加载完
      if ((((this.data.chaxunjg) % this.data.limits) == 0) && (totleCont == nowCont)) {
        xhs.showToast({
          title: '我是有底线哒',
          duration: 2000
        })
      } else if ((((this.data.chaxunjg) % this.data.limits) > 0) && (totleCont < (nowCont + 1))) {
        xhs.showToast({
          title: '我是有底线哒',
          duration: 2000
        })
      } else {
        // 注入新数据---重新走接口
        this.setData({
          fypage: this.data.fypage + 1,
          ['grdata.page']: this.data.fypage + 1
        })
        await this.chaxun(this.data.grdata)
      }
    }
  },
  // 收藏/取消收藏
  collect: async function (e) {
    if (this.data.myPhone != '') {
      let { ggid, zwid, index, action } = e.currentTarget.dataset;
      xhs.showLoading({
        title: action == 'collect' ? '收藏中！' : '取消收藏中！',
        icon: 'none',
        duration: 2000,
      })
      let { cxlists } = this.data;
      let data = {
        ggid,
        zwid,
        action,
        phone: this.data.myPhone,
      }
      let collectData = await this.updateCollect(data)
      xhs.hideLoading({})
      xhs.showToast({
        title: collectData == 1 ? action == 'collect' ? '添加收藏成功!' : '取消收藏成功!' : '操作失败',
        icon: 'success',
        duration: 1500
      })
      if(collectData == 1) {
        action == 'collect' ? cxlists[index].collect = true : cxlists[index].collect = false;
        this.setData({
          cxlists
        })
      }
    } else {
      xhs.showToast({
        title: '请先注册',
        duration: 2000
      })
      this.setData({
        isShowAuth: !0,
      })
      return false
    }


  },

  // 收藏和取消的方法
  updateCollect(data) {
    return new Promise((resolve) => {
      jiatuiRequest({
        url: '/api/v1/moonshot/collectPosition',
        method: 'post',
        dataType: 'jsonp',
        header: {
          'X-Requested-From': 'WeChatMiniProgram'
        },
        data,
      }).then(res => {
        if (res.code == 0) {
          resolve(1)
        } else {
          resolve(0)
        }
      }).catch(err => {
        resolve(0)
      })
    })
  },
  //去往个人收藏
  goToMyCenter: function () {
    const { id, gh, fx, lx, name } = this.data.options;
    xhs.navigateTo({
      url: `./mycenter?id=${id}&gh=${gh}&fx=${fx}&lx=${lx}&name=${name}`
    })
  },
  // 回到顶部
  toTop() {
    xhs.pageScrollTo({
      scrollTop: 0
    })
  },
  // 该怎么就怎么
  thisMethod: async function () {
    if (this.data.user && this.data.user.status == 1) {
      if (!this.data.user.user.gwlb && (this.data.options.lx == 'sydw' || this.data.options.lx == 'jztg')) {
        this.setData({
          xiangmuok: true
        })
      }
      if (!this.data.user.user.zhunkaozheng && this.data.ms == 0) {
        this.setData({
          zhunkaozhengok: true
        })
      } else {
        this.setData({
          zhunkaozhengok: false
        })
      }
    } else {
      if (this.data.options.lx == 'sydw' || this.data.options.lx == 'jztg') {
        this.setData({
          xiangmuok: true
        })
      }
    }
    if(this.data.myPhone) {
      if (!this.data.user) {
        await app.methods.registerCX(this.data.myPhone, this.data.options.actid, this.data.laiyuan, this.data.isSydw, this.data.getIdentity, this.data.bklxvalue, '', '', 'chaxun')
        this.setData(await app.methods.getphonestatusCX(this.data.myPhone, this.data.options.actid, 'chaxun'))
      } else {
        await app.methods.updateuserCX(this.data.myPhone, this.data.options.actid, this.data.laiyuan, (this.data.isSydw || this.data.isYiShi), this.data.getIdentity, this.data.user.user.gwlb, '', 'chaxun', this.data.book, this.data.user.user)
        this.setData(await app.methods.getphonestatusCX(this.data.myPhone, this.data.options.actid, 'chaxun'))
      }
    }
  },
  // 展开和收起
  toggle: function (e) {
    const { index } = e.currentTarget.dataset;
    let { cxlists } = this.data;
    cxlists[index].toggle = !cxlists[index].toggle
    this.setData({
      cxlists
    })
  },
  // 处理专业代码
  removeNumbersAndLetters(str) {
    return str.replace(/[a-zA-Z0-9]/g, '');
  },
  // 监听手机号
  async user_login(e){
    if(typeof e.detail == 'boolean') {
        this.setData({
            isShowAuth: e.detail
        })
    } else {
        this.setData({
            myPhone: e.detail
        })
        this.setData(await app.methods.getphonestatusCX(this.data.myPhone, this.data.options.actid, 'chaxun'));
        await this.thisMethod();
    }
  },
  /**
   * 生命周期函数--监听页面初次渲染完成---从个人中心页面返回，
   */
  async onShow() {
    if (this.data.grdata.limits == this.data.limits) {
      this.setData({
        cxlists: [],
        collectLists: [],
        fypage: 1,
        ['grdata.page']: 1
      })
      await this.chaxun(this.data.grdata)
    } else {

    }


  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {
    let { fx = 'hbwtb', gh = 'zcj37368', id, name } = this.data.options;
    console.log(`/packageB/zwjs/zwjs?id=${id}&fx=${fx}&gh=${gh}`)
    return {
      title: name,
      path: `/packageB/zwjs/zwjs?id=${id}&fx=${fx}&gh=${gh}`,
      imageUrl: 'https://statics.offcn.com/hb/pc/images/wxxcx/shareImg/skzwjs.jpg',
    }
  },
})